import request from '@/utils/request'
import upload from '@/utils/upload'

import type {
    getDriverTaskParams,
    CancelWaybillShipParams,
    useWaybillShipCodeParams,
    getAssignorParams,
    SignContractParams,
    authVideoParams,
    openAnxinqianParams,
    getAnxinqianCodeParams,
    confirmAnxinqianCodeParams,
    bindSmsCodeParams,
    getBankListParams,
    getWithdrawalRecordParams,
    getAgreementParams,
    getCommentParams,
    authenticationParams,
    pushPositionParams
} from '@/types'

//获取用户状态，是否实名认证或委托人认证
export const judgeIdentify = () => {
    return request({
        url: '/app/isRealAuth',
        method: 'get'
    })
}

// 司机查询运单发运完整信息集合（含分页）
export const getDriverTask = (data: getDriverTaskParams) => {
    return request({
        url: '/app/waybillShip/getDriverWaybillShipInfoPage',
        data,
        method: 'post'
    })
}

// 查看打卡
export const getWaybillClock = (data: any) => {
    return request({
        url: '/waybillShip/getWaybillShipClock',
        method: 'post',
        data
    })
}

// 起运
export const DepartureWaybill = (data:any) => {
    return request({
        url: '/app/waybillShip/departure',
        method: 'post',
        data
    })
}

// 到达
export const ReachWaybill = (data:any) => {
    return request({
        url: '/app/waybillShip/waybillShipArrive',
        method: 'post',
        data
    })
}

// 上传回单
export const receiptWaybill = (data:any) => {
    return request({
        url: '/app/waybillShip/receipt',
        method: 'post',
        data
    })
}

// 取消订单
export const CancelWaybillShip = (data:CancelWaybillShipParams) => {
    return request({
        url: '/app/waybillShip/driverCancelWaybillShip',
        method: 'post',
        data
    })
}

// 使用运单码
export const useWaybillShipCode = (data:useWaybillShipCodeParams) => {
    return request({
        url: '/waybill/code/useCode',
        method: 'post',
        data
    })
}

// 接单(不签署合同，直接接单)
export const SignForWaybill = (data:any) => {
    return request({
        url: '/app/waybillShip/receiveSignFor',
        method: 'post',
        data
    })
}

// 查询委托信息集合
export const getAssignor = (data?:getAssignorParams) => {
    return request({
        url: '/app/assignor/info/getDriverAssignorInfoPage',
        data,
        method: 'post'
    })
}

// 创建并签署委托合同
export const SignContract = (data:SignContractParams) => {
    return request({
        url: '/app/assignor/info/createSignAssignorContract',
        data,
        method: 'post'
    })
}

// 已关联企业列表
export const Entlist = (data:any) => {
    return request({
        url: '/app/truckDriver/getRelateEnt',
        method: 'get',
        data
    })
}

// 查找个人信息
export const getInfo = () => {
    return request({
        url: '/app/truckDriver/getTruckerDriver',
        method: 'get'
    })
}

// 实名认证
export const toAuth = (data:any) => {
    return request({
        url: '/app/truckDriver/updateTruckerDriver',
        data,
        method: 'post'
    })
}

// 查询企业是否被关联
export const haslinkEnt = (relateEntCode:string) => {
    return request({
        url: '/app/truckDriver/verifyDriverHasRelateEnt',
        method: 'post',
        data: {
            relateEntCode
        }
    })
}

// 关联企业
export const linkEnt = (relateEntCode:string) => {
    return request({
        url: '/app/truckDriver/useTruckerDriverCode',
        data: {
            relateEntCode
        },
        method: 'post'
    })
}

// 活体验证上传视频
export const authVideo = (filePath: string, formData: authVideoParams) => {
    return upload({
        url: '/app/assignor/videoRealAuth',
        filePath,
        formData,
        timeout: 3000 * 1000
    })
}

// 获取司机安心签开户状态
export const getAnxinqianOpenStatus = () => {
    return request({
        url: '/app/truckDriver/findUserAnxinqianInfo',
        method: 'get'
    })
}

// 司机安心签开户
export const openAnxinqian = (data:openAnxinqianParams) => {
    return request({
        url: '/app/truckDriver/openAnxinqian',
        method: 'post',
        data
    })
}

// 司机安心签发送验证码
export const getAnxinqianCode = (data:getAnxinqianCodeParams) => {
    return request({
        url: '/app/anxinqian/sendVerifyCode',
        method: 'get',
        data
    })
}

// 验证司机安心签验证码
export const confirmAnxinqianCode = (data:confirmAnxinqianCodeParams) => {
    return request({
        url: '/app/truckDriver/confirmVerifyCode',
        method: 'get',
        data
    })
}

// 修改委托人证件信息
export const updateAssignorInfo = (data:any) => {
    return request({
        url: '/app/assignor/updateUserInfo',
        method: 'post',
        data
    })
}

// 修改回单
export const updateReceiptWaybill = (data:any) => {
    return request({
        url: '/app/waybillShip/updateReceipt',
        method: 'post',
        data
    })
}

// 查询收款账号余额
export const getmoney = () => {
    return request({
        url: '/beneficiaryAccountNo/getBalance',
        method: 'post'
    })
}

// 发送绑定银行卡短信验证码
export const bindSmsCode = (data:bindSmsCodeParams) => {
    return request({
        url: '/app/assignor/sendBindSmsCode',
        method: 'post',
        data
    })
}

// 委托人添加银行卡
export const addBankCard = (data:any) => {
    return request({
        url: '/app/assignor/saveUserAccountNo',
        data,
        method: 'post'
    })
}

// 获取银行列表
export const getBankList = (data:getBankListParams) => {
    return request({
        url: '/app/assignor/getSuperBankCodePage',
        method: 'post',
        data
    })
}

// 绑定提现账户小额鉴权（发送验证短信）
export const getSmallAmountCode = (data:any) => {
    return request({
        url: '/app/assignor/bindSmallAmountWithCheckCorp',
        method: 'post',
        data
    })
}

// 小额鉴权回填金额（填写短信验证信息）
export const checkAmountWithCorp = (data:any) => {
    return request({
        url: '/app/assignor/checkAmountWithCorp',
        method: 'post',
        data
    })
}

// 委托人查询银行卡集合
export const accountNoPage = () => {
    return request({
        url: '/app/assignor/getUserAccountNoPage',
        data: {},
        method: 'post'
    })
}

// 提现收款子账号金额到个人银行卡
export const reflbankcard = (data:any) => {
    return request({
        url: '/app/assignor/withdrawUserAccountNo',
        data,
        method: 'post'
    })
}

// 发送提现短信验证码
export const withdrawSmsCode = (data:any) => {
    return request({
        url: '/app/assignor/sendWithdrawSmsCode',
        method: 'post',
        data
    })
}

// 用户查询银行提现信息
export const getWithdrawalRecord = (data:getWithdrawalRecordParams) => {
    return request({
        url: '/app/assignor/getUserTransationPageByUser',
        method: 'post',
        data
    })
}

// 获取签约中心协议
export const getAgreement = (data:getAgreementParams) => {
    return request({
        url: '/app/contract/getUserContractPage',
        method: 'post',
        data
    })
}

// 保存运单评论
export const saveComment = (data:any) => {
    return request({
        url: '/app/waybill/addComment',
        method: 'post',
        data
    })
}

// 查询运单评价
export const getComment = (params:getCommentParams) => {
    return request({
        url: '/app/waybill/listComment',
        method: 'get',
        params
    })
}

// 委托人认证
export const authentication = (data:authenticationParams) => {
    return request({
        url: '/app/assignor/updateFile',
        method: 'post',
        data
    })
}

// 委托人活体验证上传视频
export const assignorAuthVideo = (filePath: string, formData:any) => {
    return upload({
        url: '/app/assignor/videoRealAuth',
        filePath,
        formData: {
            ...formData,
            realStatus: 'ASSIGNOR_REAL'
        },
        timeout: 3000 * 1000
    })
}

// 运单推送位置
export const pushPosition = (data:pushPositionParams) => {
    return request({
        url: '/app/waybillShip/saveVehicleTrajectory',
        method: 'post',
        data
    })
}